myApp.factory('$serAlert', ['$timeout','$rootScope', function($timeout,$rootScope) {
    var alertLogTime;
    $rootScope.alert = {
        log:{
            state:false,
            text:null
        }
    };
    return {
        log : function(text){
            if($rootScope.alert.log.state){
                $timeout.cancel(alertLogTime);
            }
            var scrollTop=document.body.scrollTop||document.documentElement.scrollTop;
            document.getElementById('alert').style.marginTop = scrollTop+'px';
            $rootScope.alert.log.state = true;
            $rootScope.alert.log.text = text;
            //提示框显示最多1.5秒消失
            var _self = this;
            var alertLogTime = $timeout(function(){
                document.getElementById('alert').style.marginTop = 0;
                $rootScope.alert.log.state = false;
                $rootScope.alert.log.text = null;
            },1500);

        }
    };
}]);